package com.bawei.rk_01.fm

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.ViewDataBinding
import com.bawei.base.utils.mvvm.BaseFragment
import com.bawei.rk_01.Adapter.LqCouponsAdapter
import com.bawei.rk_01.Home.LqCouponsViewModel
import com.bawei.rk_01.R
import com.bawei.rk_01.databinding.FragmentCoupons1Binding


class CouponsFragment1 : BaseFragment<FragmentCoupons1Binding,LqCouponsViewModel>() {

    lateinit var lqCouponsAdapter: LqCouponsAdapter

    override fun getViewModel(): Class<LqCouponsViewModel> {
        return LqCouponsViewModel::class.java
    }

    override fun getLayout(): Int {
        return R.layout.fragment_coupons1
    }

    override fun initView() {

        lqCouponsAdapter = LqCouponsAdapter()
        viewModel.lqcoupons("5","1","usable")
        binding.rvCou.adapter = lqCouponsAdapter

    }

    override fun initData() {

        viewModel.lqsuccess.observe(this){
            if (it.code == 200){
                lqCouponsAdapter.data.clear()
                lqCouponsAdapter.data.addAll(it.data.list)
                lqCouponsAdapter.notifyDataSetChanged()
            }
        }

    }

}